package com.yang.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yang.model.Menu;
import com.yang.model.User;
import com.yang.service.MenuService;
import com.yang.service.UserService;

@Controller
public class UserController {

	@Resource
	private UserService userService;
	@Resource
	private MenuService menuService;
	
	
	@RequestMapping("login")
	public String doLogin(String username,String password,Model model) {		
		boolean login = userService.login(new User(username,password));
		if (login) {
			List<Menu> menuList = menuService.getMenuList();
			StringBuffer buffer =new StringBuffer();
			buffer.append("<ul id=\"browser\" class=\"filetree treeview-famfamfam\">");
			for (Menu menu : menuList) {
				if (menu.getFather_id()==0) {
					
				}
			}
			buffer.append("</ul>");
			model.addAttribute("menuList", buffer.toString());
		}
		return "one";
	}
	
}
